﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using PMSGSC.DAL;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Linq;

namespace PMSGSC.App
{
    public partial class rpStockOut : DevExpress.XtraReports.UI.XtraReport
    {
        public rpStockOut(List<InvoiceDetail> dataSource)
        {
            InitializeComponent();

            bindingSource1.DataSource = dataSource;
            xrLabel2.Text = DateTime.Now.Date.ToString("MM/dd/yyyy");
            OpenDocument();
        }

        private void OpenDocument()
        {
            string Address = Application.StartupPath + "\\Attachment\\";
            Directory.CreateDirectory(Address);
            if (null != bindingSource1.DataSource)
            {
                InvoiceDetail invoiceDetail = bindingSource1.Cast<InvoiceDetail>().ToList()[0];
                string fileName = invoiceDetail.Invoice.Ship.NameShip + invoiceDetail.Invoice.Ship.Extension;
                Address += fileName;
                xrPictureBox1.ImageUrl = Address;
            }
        }

    }
}
